package com.wc.AlgoOJ_homework.AlgoOJ_HomeWork2.S_斐波那契数组;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/6 17:20
 * @description http://43.138.190.70:8888/p/565?tid=65e6b15c27489dab814f8d41
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int M = (int) 1e6;
    static int[] a = new int[N];
    static int n;
    // 原始的斐波那契数组
    static int[] origin = new int[N];
    // 记录倍数
    static int[] cnt = new int[N];

    public static void main(String[] args) {
        origin[1] = 1;
        origin[2] = 1;
        int maxN = 0;
        for (int i = 3; i < N; i++) {
            origin[i] = origin[i - 1] + origin[i - 2];
            if (origin[i] > M) {
                maxN = i;
                break;
            }
        }
        n = sc.nextInt();
        int bound = Math.min(n, maxN - 1);
        int maxCnt = 0;
        int maxMul = 0;
        // 超过maxN的一定需要改
        int res = Math.max(0, n - maxN + 1);
        // 这里有点问题
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
        for (int i = 1; i <= bound; i++) {
            if (a[i] % origin[i] == 0) {
                int re = a[i] / origin[i];
                cnt[re]++;
                if (cnt[re] > maxCnt) {
                    maxCnt = cnt[re];
                    maxMul = re;
                }
            }
        }
        if (maxMul == 0) out.println(n);
        else {

            for (int i = 1; i <= bound; i++) {
                if (origin[i] * maxMul != a[i]) {
                    res++;
                }
            }
            out.println(res);
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
